#include "head.h"

int initThreadPoll(thread_poll *poll, int num){
    pthread_cond_init(&poll->cond, NULL);
    pthread_mutex_init(&poll->lock, NULL);
    pthread_t *tids = (pthread_t*)calloc(sizeof(pthread_t),num);
    poll->tids = tids;
    poll->thread_num = num;
    bzero(&poll->sessions,sizeof(queue_t));
    poll->sessions.queue_size = 0;
    poll->exit_flag = 0;
    for(int i=0; i<num; i++){
        pthread_t tid;
        pthread_create(&tid,NULL,threadMain,poll);
        poll->tids[i]=tid;
    }
    return 0;
}
